package com.hnevc.androidui10;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

import com.google.gson.Gson;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        String json1 = "{\"name\":\"zhangsan\",\"age\":27,\"married\":true}";

        //创建解析对象
        Gson gson = new Gson();
        //完成解析
        Person person = gson.fromJson(json1,Person.class);
        //验证是否已解析成功
        Toast.makeText(this, person.getName(), Toast.LENGTH_SHORT).show();


    }
}
